#pragma once
#include <iostream>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <string>

using namespace std;
struct data
{
	list<int> obs;
	string time, rikt1, rikt2;
	data()
	{
		rikt1 = "";
		rikt2 = "";
		time = "";
	}


	data(string time, string rikt1, string rikt2)
	{
		this->rikt1 = rikt1;
		this->rikt2 = rikt2;
		this->time = time;
	}

};
class observatory
{

private:
	map<string, data> Mupp;

public:

	observatory(void)
	{
	}

	void readSignals(string file)
	{
		ifstream filein;
		int Hubble;
		string time, r1, r2;
		string key;
		filein.open(file);
		while(!filein.eof())
		{
			filein >> Hubble;
			filein >> time;
			filein >> r1;
			filein >> r2;
			key = time+" "+r1+","+r2;
			Mupp.insert(pair<string,data>(key,data(time,r1,r2)));
			Mupp[key].obs.push_back(Hubble);
		}
		Mupp[key].obs.pop_back();
	}

	void print()
	{
		for(auto &i : Mupp)
		{
			if(Mupp[i.first].obs.size() > 1)
			{
				cout << "Tid: " << i.second.time << "  Riktning: " << i.second.rikt1 << " " << i.second.rikt2 << "  Observatorier: ";
				for (list<int>::iterator it=i.second.obs.begin(); it != i.second.obs.end(); ++it)
				{
					cout << *it << " ";
				}
				cout << endl;
			}
		}


	}

	~observatory(void)
	{
	}

};

